#!/usr/bin/env python

pwm_min = 110
steps = 20	 
pwm_max = 255
base = 70

pwm_values = list()

steps += 1;
for x in range(0,steps):
	y = round( (base**(x/(steps-1)) -1)/(base -1) * pwm_max )
	pwm_values.append(y)
pwm_values = pwm_values[1:]

cstring = "#define BLSTEPS {:n} /**< @brief size of backlight pwm table */\n\n".format(steps)
cstring += "/** @brief backlight pwm table */\n"
cstring += "const __flash uint8_t blpwm[BLSTEPS] = {"

place = 0
nl_after=60
for y in pwm_values:
	if (place%nl_after == 0):
		fill = "\n\t"
	else:
		fill = " "
	if (place == nl_after):
		place = 0

	valstr= "{:s}{:n},".format(fill,y)
	cstring += valstr

	place += len(valstr)	
	if (place > nl_after):
		place = nl_after

lastcomma = cstring.rfind(',')

cstring = cstring[:lastcomma]
cstring += "\n};\n"

print(cstring,end="")
